package com.example.myapplication;

import android.Manifest;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class MyActivity extends AppCompatActivity {



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        List<String> powerList = new ArrayList<String>();
        powerList.add(Manifest.permission.READ_EXTERNAL_STORAGE);
        powerList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
        powerList.add(Manifest.permission.RECORD_AUDIO);
        powerList.add(Manifest.permission.READ_PHONE_STATE);
        powerList.add(Manifest.permission.READ_PHONE_NUMBERS);
        powerList.add(Manifest.permission.FOREGROUND_SERVICE);
        if (powerList.size() != 0) {
            String[] requestPermissions = new String[powerList.size()];
            String[] arrays = powerList.toArray(requestPermissions);
            ActivityCompat.requestPermissions(this, arrays, 111);
        }
        Intent intent=new Intent(this,PhoneListenService.class);
        startService(intent);
        Toast.makeText(this, "服务启动", Toast.LENGTH_SHORT).show();

    }

}
